public class BubbleSort {
    public static void main(String[] args) {
        int[] arr = {4,6,8,2,2,3,1,9,8,33};
        int[] arr1 = {1,2,3,4,5,6,7,8,9,10};
        bubble(arr);
        bubble(arr1);
        for (int i = 0; i < arr1.length; i++) {
            System.out.print(arr1[i] + " ");
        }
    }
    private static void bubble(int[] arr) {
        for (int i = 0; i <= arr.length-1; i++) {
            boolean flag = true;
            for (int j = 0; j < arr.length-1; j++) {
                if(arr[j] > arr[j+1]) {
                    int tmp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = tmp;
                    flag = false;
                }

            }if(flag) {
                break;
            }
        }
    }
}
